$(function(){
	cheeksubject();
})
function cheeksubject(){
	$.ajax({
		url : "/blackhouse/gradesub",
		type:"post",
		data:{"code":0},
		dataType:"json",
		success:function(e){
			var html = "";
			for(var i = 0;i<e.length;i++){
				html+="<tr>";
				html+="<td>"+e[i].subjectcode+"</td>";
				html+="<td>"+e[i].subjectname+"</td>";
				html+="<td>"+e[i].teacher+"</td>";
				html+="<td>"+e[i].createTime+"</td>";
				html+="<td>"+e[i].gradeName+"</td>";
				html+="<td><a tag="+e[i].id+" onclick='delsubject(this)'>删除</a></td>";
				html+="</tr>";
			}
			$("#gradesub-tbody").html(html);
		}
	});
}
function delsubject(e){
	var r=confirm("确认删除该科目信息吗");
	if (r==true)
	{
	var key = $(e).attr("tag");
	$.ajax({
		url : "/blackhouse/gradesub",
		type:"post",
		data:{"code":1,"key":key},
		dataType:"json",
		success:function(e){
			if(e){
				alert("删除失败");
			}else{
				alert("删除成功");
				cheeksubject()
			}
		}
	});
	}
}